package routes

import (
	"gin/api"
	"gin/config"
	"gin/middleware"

	"github.com/gin-gonic/gin"
)

func SetupRoute() {
	gin.SetMode(config.AppMode)
	r := gin.Default()
	r.Use(middleware.Cors())

	r.GET("/", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"code": 200,
			"data": "",
		})
	})
	// 普通路由
	router := r.Group("api")
	{
		router.POST("login", api.Login)
		router.GET("login/status", api.LoginStatus)
	}
	// JWT 认证路由
	auth := r.Group("user")
	auth.Use(middleware.JwtToken())
	{
		auth.GET("info", api.Info)
	}

	_ = r.Run(config.HttpPort)
}
